home *** CD-ROM | disk | FTP | other *** search
/ Transformers: Revenge of …he Game: Press Kit (USA) / Transformers - Revenge of the Fallen - The Game - Press Kit (USA).bin / Transformers.swf / scripts / fl / video / VolumeBarAccImpl.as < prev   
Text File  |  2009-06-19  |  9KB  |  295 lines

  1. package fl.video
  2. {
  3.    import flash.accessibility.Accessibility;
  4.    import flash.accessibility.AccessibilityImplementation;
  5.    import flash.accessibility.AccessibilityProperties;
  6.    import flash.display.DisplayObject;
  7.    import flash.display.Sprite;
  8.    import flash.events.Event;
  9.    import flash.events.FocusEvent;
  10.    import flash.utils.Dictionary;
  11.    
  12.    use namespace flvplayback_internal;
  13.    
  14.    public class VolumeBarAccImpl extends AccessibilityImplementation
  15.    {
  16.       
  17.       private static const ROLE_SYSTEM_INDICATOR:uint = 39;
  18.       
  19.       private static const ROLE_SLIDER:uint = 51;
  20.       
  21.       private static const STATE_SYSTEM_FOCUSABLE:uint = 1048576;
  22.       
  23.       private static const EVENT_OBJECT_SELECTION:uint = 32774;
  24.       
  25.       private static const ROLE_SYSTEM_PUSHBUTTON:uint = 43;
  26.       
  27.       private static const STATE_SYSTEM_FOCUSED:uint = 4;
  28.       
  29.       private static const STATE_SYSTEM_SELECTABLE:uint = 2097152;
  30.       
  31.       private static const ROLE_WINDOW:uint = 9;
  32.       
  33.       private static const EVENT_OBJECT_FOCUS:uint = 32773;
  34.       
  35.       private static const STATE_SYSTEM_SELECTED:uint = 2;
  36.       
  37.       private static const EVENT_OBJECT_VALUECHANGE:uint = 32782;
  38.       
  39.       private static const EVENT_OBJECT_LOCATIONCHANGE:uint = 32779;
  40.       
  41.       private static const STATE_SYSTEM_NORMAL:uint = 0;
  42.       
  43.       private static const STATE_SYSTEM_UNAVAILABLE:uint = 1;
  44.        
  45.       
  46.       protected var master:Sprite;
  47.       
  48.       protected var role:uint;
  49.       
  50.       private var _vc:FLVPlayback;
  51.       
  52.       public function VolumeBarAccImpl(param1:Sprite)
  53.       {
  54.          var n:int = 0;
  55.          var i:int = 0;
  56.          var sprite:Sprite = param1;
  57.          super();
  58.          stub = false;
  59.          master = sprite;
  60.          if(!master.accessibilityProperties)
  61.          {
  62.             master.accessibilityProperties = new AccessibilityProperties();
  63.          }
  64.          master.accessibilityProperties.forceSimple = true;
  65.          var events:Array = eventsToHandle;
  66.          if(events)
  67.          {
  68.             n = events.length;
  69.             i = 0;
  70.             while(i < n)
  71.             {
  72.                master.addEventListener(events[i],eventHandler);
  73.                i++;
  74.             }
  75.          }
  76.          master.addEventListener(FocusEvent.FOCUS_IN,focusInHandler);
  77.          try
  78.          {
  79.             _vc = Object(master).uiMgr._vc;
  80.             _vc.addEventListener(SoundEvent.SOUND_UPDATE,eventHandler);
  81.          }
  82.          catch(e:Error)
  83.          {
  84.          }
  85.          role = VolumeBarAccImpl.ROLE_SLIDER;
  86.       }
  87.       
  88.       public static function createAccessibilityImplementation(param1:Sprite) : void
  89.       {
  90.          param1.accessibilityImplementation = new VolumeBarAccImpl(param1);
  91.       }
  92.       
  93.       public static function enableAccessibility() : void
  94.       {
  95.       }
  96.       
  97.       override public function get_accState(param1:uint) : uint
  98.       {
  99.          return uint(getState(param1));
  100.       }
  101.       
  102.       protected function getName(param1:uint) : String
  103.       {
  104.          var _loc2_:String = "";
  105.          switch(param1)
  106.          {
  107.             case 1:
  108.                _loc2_ = "Page Left";
  109.                break;
  110.             case 2:
  111.                _loc2_ = "Position";
  112.                break;
  113.             case 3:
  114.                _loc2_ = "Page Right";
  115.                break;
  116.             case 0:
  117.                _loc2_ = "";
  118.          }
  119.          return _loc2_;
  120.       }
  121.       
  122.       override public function get_accName(param1:uint) : String
  123.       {
  124.          var _loc2_:String = "";
  125.          if(param1 == 0 && master.accessibilityProperties && master.accessibilityProperties.name && master.accessibilityProperties.name != "")
  126.          {
  127.             _loc2_ += master.accessibilityProperties.name + " ";
  128.          }
  129.          _loc2_ += getName(param1) + getStatusName();
  130.          return _loc2_ != null && _loc2_ != "" ? _loc2_ : null;
  131.       }
  132.       
  133.       override public function get_accDefaultAction(param1:uint) : String
  134.       {
  135.          if(param1 == 1 || param1 == 3)
  136.          {
  137.             return "Press";
  138.          }
  139.          return null;
  140.       }
  141.       
  142.       protected function getState(param1:uint) : uint
  143.       {
  144.          var _loc2_:uint = STATE_SYSTEM_NORMAL;
  145.          if(param1 == 0)
  146.          {
  147.             if(!master.mouseEnabled || !master.tabEnabled)
  148.             {
  149.                _loc2_ |= STATE_SYSTEM_UNAVAILABLE;
  150.             }
  151.             else
  152.             {
  153.                _loc2_ |= STATE_SYSTEM_FOCUSABLE;
  154.             }
  155.             if(Sprite(master).stage.focus == master)
  156.             {
  157.                _loc2_ |= STATE_SYSTEM_FOCUSED;
  158.             }
  159.          }
  160.          return _loc2_;
  161.       }
  162.       
  163.       override public function accDoDefaultAction(param1:uint) : void
  164.       {
  165.          var _loc2_:UIManager = _vc.uiMgr as UIManager;
  166.          var _loc3_:Boolean = _loc2_._isMuted;
  167.          var _loc4_:Number = !!_loc3_ ? Number(Math.round(_loc2_.cachedSoundLevel * 1000) / 100) : Number(Math.round(_vc.volume * 1000) / 100);
  168.          if(param1 == 1)
  169.          {
  170.             if(Math.floor(_loc4_) != _loc4_)
  171.             {
  172.                _vc.volume = Math.floor(_loc4_) / 10;
  173.             }
  174.             else
  175.             {
  176.                _vc.volume = Math.max(0,(_loc4_ - 1) / 10);
  177.             }
  178.          }
  179.          else if(param1 == 3)
  180.          {
  181.             if(Math.round(_loc4_) != _loc4_)
  182.             {
  183.                _vc.volume = Math.round(_loc4_) / 10;
  184.             }
  185.             else
  186.             {
  187.                _vc.volume = Math.min(1,(_loc4_ + 1) / 10);
  188.             }
  189.          }
  190.          _loc2_.cachedSoundLevel = _vc.volume;
  191.          if(_loc3_)
  192.          {
  193.             _loc2_._isMuted = true;
  194.             _loc2_.cachedSoundLevel = _vc.volume;
  195.             _vc.volume = 0;
  196.             _loc2_.setEnabledAndVisibleForState(UIManager.MUTE_OFF_BUTTON,VideoState.PLAYING);
  197.             _loc2_.skinButtonControl(_loc2_.controls[UIManager.MUTE_OFF_BUTTON]);
  198.             _loc2_.setEnabledAndVisibleForState(UIManager.MUTE_ON_BUTTON,VideoState.PLAYING);
  199.             _loc2_.skinButtonControl(_loc2_.controls[UIManager.MUTE_ON_BUTTON]);
  200.          }
  201.       }
  202.       
  203.       private function focusInHandler(param1:Event) : void
  204.       {
  205.          if(Accessibility.active)
  206.          {
  207.             Accessibility.sendEvent(master,0,EVENT_OBJECT_FOCUS);
  208.             Accessibility.sendEvent(master,0,EVENT_OBJECT_VALUECHANGE,true);
  209.          }
  210.       }
  211.       
  212.       override public function get_accRole(param1:uint) : uint
  213.       {
  214.          if(param1 == 0)
  215.          {
  216.             return role;
  217.          }
  218.          if(param1 == 2)
  219.          {
  220.             return ROLE_SYSTEM_INDICATOR;
  221.          }
  222.          return ROLE_SYSTEM_PUSHBUTTON;
  223.       }
  224.       
  225.       protected function eventHandler(param1:Event) : void
  226.       {
  227.          if(param1.type == SoundEvent.SOUND_UPDATE)
  228.          {
  229.             if(Accessibility.active)
  230.             {
  231.                Accessibility.sendEvent(master,0,EVENT_OBJECT_SELECTION);
  232.                Accessibility.sendEvent(master,0,EVENT_OBJECT_VALUECHANGE,true);
  233.             }
  234.          }
  235.       }
  236.       
  237.       override public function get_accValue(param1:uint) : String
  238.       {
  239.          var _loc2_:Number = NaN;
  240.          if(param1 == 0)
  241.          {
  242.             _loc2_ = Math.round(_vc.volume * 10000) / 100;
  243.             return String(_loc2_) + "%";
  244.          }
  245.          return null;
  246.       }
  247.       
  248.       private function getStatusName() : String
  249.       {
  250.          return "";
  251.       }
  252.       
  253.       protected function get eventsToHandle() : Array
  254.       {
  255.          return [];
  256.       }
  257.       
  258.       override public function accLocation(param1:uint) : *
  259.       {
  260.          var _loc7_:DisplayObject = null;
  261.          var _loc2_:Object = master;
  262.          var _loc3_:UIManager = _vc.uiMgr as UIManager;
  263.          var _loc4_:DisplayObject = _loc3_.controls[UIManager.VOLUME_BAR] as DisplayObject;
  264.          var _loc5_:Dictionary;
  265.          var _loc6_:ControlData = (_loc5_ = UIManager(_loc3_).ctrlDataDict as Dictionary)[_loc4_];
  266.          if(_loc5_[_loc6_.fullness_mc].mask_mc)
  267.          {
  268.             _loc7_ = DisplayObject(_loc5_[_loc6_.fullness_mc].mask_mc);
  269.          }
  270.          switch(param1)
  271.          {
  272.             case 1:
  273.             case 3:
  274.                if(_loc7_)
  275.                {
  276.                   _loc2_ = _loc7_;
  277.                }
  278.          }
  279.          return _loc2_;
  280.       }
  281.       
  282.       override public function getChildIDArray() : Array
  283.       {
  284.          var _loc1_:Array = [];
  285.          var _loc2_:uint = 0;
  286.          while(_loc2_ < 3)
  287.          {
  288.             _loc1_[_loc2_] = _loc2_ + 1;
  289.             _loc2_++;
  290.          }
  291.          return _loc1_;
  292.       }
  293.    }
  294. }
  295.